package com.nbcio.iot.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.nbcio.common.tenant.core.TenantEntity;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 设备对象 iot_device
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("iot_device")
public class IotDevice extends TenantEntity {

    @TableId(value = "device_id", type = IdType.ASSIGN_ID)
    private Long deviceId;

    @NotBlank(message = "设备名称不能为空")
    @TableField("device_name")
    private String deviceName;

    @NotBlank(message = "设备编码不能为空")
    @TableField("device_code")
    private String deviceCode;

    @NotNull(message = "产品ID不能为空")
    @TableField("product_id")
    private Long productId;

    /**
     * 通信协议类型（可覆盖产品）
     */
    @TableField("protocol_type")
    private String protocolType;

    /**
     * 协议配置覆盖（JSON，仅填写需要覆盖的键）
     */
    @TableField("protocol_config_override")
    private String protocolConfigOverride;

    /**
     * 绑定的 Node-RED 规则ID（可选）
     */
    @TableField("flow_id")
    private Long flowId;

    @TableField("group_id")
    private Long groupId;

    @TableField("device_ip")
    private String deviceIp;

    @TableField("device_port")
    private Integer devicePort;

    @TableField("device_status")
    private String deviceStatus;

    @TableField("location")
    private String location;

    @TableField("longitude")
    private BigDecimal longitude;

    @TableField("latitude")
    private BigDecimal latitude;

    @TableField("install_time")
    private LocalDateTime installTime;

    @TableField("last_online_time")
    private LocalDateTime lastOnlineTime;

    @TableField("remark")
    private String remark;
}
